@extends('admin.readLayout')
@section('barName','提现详情')

@section('content')
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>提现详情</legend>
    </fieldset>
    <div class="layui-container">

        <blockquote class="layui-elem-quote layui-quote-nm">
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">用户</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$model->member->nickname}}</div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">金额</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">￥{{number_format($model->price,2)}}</div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">银行卡卡号</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$model->bank_id or '-'}} </div>
                    <div class="grid-demo" style="padding-bottom: 8px;padding-top: 8px">
                        @if(isset($model->bank_id)&&$model->bank_id)<img src="{{getBankImg($model->bank_id)}}"/>@endif
                    </div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">姓名</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$model->username or '-'}}</div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">状态</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$model->status_name}}</div>
                </div>
            </div>
            <div class="layui-row">
                <div class="layui-col-xs4">
                    <div class="grid-demo grid-demo-bg1">类型</div>
                </div>
                <div class="layui-col-xs8">
                    <div class="grid-demo">{{$model->type_name}}</div>
                </div>
            </div>
        </blockquote>
        @if($model->status==\App\Http\Controllers\Admin\Finance\Service\Withdraw::STATUS_APPROVE_AWAIT)
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">申请时间</label>
                    <div class="layui-input-block">
                        <input type="text" value="{{$model->apply_time}}" readonly class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <textarea name="desc" placeholder="请输入备注..." class="layui-textarea"></textarea>
                </div>
                <div class="layui-form-item layui-form-text">
                    <p align="center">
                        <button type="button" class="layui-btn layui-btn-primary apply-it">同意申请</button>
                        <button type="button" class="layui-btn layui-btn-danger refuse-it">驳回申请</button>
                    </p>

                </div>
            </form>
        @elseif($model->status==\App\Http\Controllers\Admin\Finance\Service\Withdraw::STATUS_APPROVE)
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">同意时间</label>
                    <div class="layui-input-block">
                        <input type="text" value="{{$model->approve_time}}" readonly class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注/驳回原因</label>
                    <textarea name="desc" placeholder="请输入备注..." class="layui-textarea">{{$model->desc}}</textarea>
                </div>
                <div class="layui-form-item layui-form-text">
                    <p align="center">
                        <button type="button" class="layui-btn layui-btn-success pay-it">确认打款</button>
                        <button type="button" class="layui-btn layui-btn-danger refuse-it">驳回申请</button>
                    </p>

                </div>
            </form>
        @elseif($model->status==\App\Http\Controllers\Admin\Finance\Service\Withdraw::STATUS_PAY)
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">打款时间</label>
                    <div class="layui-input-block">
                        <input type="text" value="{{$model->pay_time}}" readonly class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">备注</label>
                    <textarea name="desc" placeholder="请输入备注..." class="layui-textarea"
                              readonly>{{$model->desc}}</textarea>
                </div>
            </form>
        @elseif($model->status==\App\Http\Controllers\Admin\Finance\Service\Withdraw::STATUS_REFUSE)
            <form class="layui-form layui-form-pane" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">驳回时间</label>
                    <div class="layui-input-block">
                        <input type="text" value="{{$model->apply_time}}" readonly class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label">驳回原因</label>
                    <textarea name="desc" placeholder="请输入备注..." class="layui-textarea"
                              readonly>{{$model->refuse_reason}}</textarea>
                </div>
            </form>
        @endif
    </div>

@endsection
@section('script')
    <script>
        //注意：折叠面板 依赖 element 模块，否则无法进行功能性操作
        layui.use(['element', 'form', 'layer', 'jquery'], function () {
            var element = layui.element;
            var form = layui.form;
            var layer = layui.layer;
            var $ = layui.jquery;
            var _url = '{{route($routePrefix)}}';
            var _id = {{$model->id}}
                $.ajaxSetup({
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                }
            });
            $(document).on('click', '.apply-it', function () {
                var _renderLoad = layer.msg('处理中...',{icon: 16,time:false,shade:0.8});

                $.post(
                    _url + "?act=apply",
                    {
                        id: _id,
                        desc: $('[name=desc]').val()
                    },
                    function (e) {
                        layer.close(_renderLoad);
                        if(e.code=='error'){
                            layer.alert(e.msg);
                            return ;
                        }
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },
                    'json'
                )
            })
            $(document).on('click', '.refuse-it', function () {
                var _renderLoad = layer.msg('处理中...',{icon: 16,time:false,shade:0.8});

                $.post(
                    _url + "?act=refuse",
                    {
                        id: _id,
                        desc: $('[name=desc]').val()
                    },
                    function (e) {
                        layer.close(_renderLoad);
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },
                    'json'
                )
            })
            $(document).on('click', '.pay-it', function () {
                var _renderLoad = layer.msg('处理中...',{icon: 16,time:false,shade:0.8});
                $.post(
                    _url + "?act=pay",
                    {
                        id: _id,
                        desc: $('[name=desc]').val()
                    },
                    function (e) {
                        //console.log(e);
                        if(e.code=='error'){
                            layer.msg(e.msg);
                            return ;
                        }

                       layer.close(_renderLoad);
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭
                    },
                    'json'
                )
            })
            //…
            $.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')}});
        });

    </script>
@endsection